package Entity;

	import java.io.BufferedReader;
	import java.io.InputStream;
	import java.io.InputStreamReader;
	import java.io.OutputStream;
	import java.io.PrintWriter;
	import java.net.Socket;

	public class Customer_sendSms{
		public Customer_sendSms(){
			}
			
		public void send(String s1, String s2){
			Socket          s   = null;
	        PrintWriter     pw  = null;
	        InputStream     is  = null;
	        OutputStream    os  = null;
	        BufferedReader  br  = null;

	        String header = "POST /SMSWebService/sms.asmx HTTP/1.1"                                     + "\r\n" +
	                        "Host: 172.20.128.62"                                                      + "\r\n" +
	                        "Content-Type: text/xml; charset=utf-8"                                     + "\r\n" +
	                        "Content-Length: $LEN"                                                      + "\r\n" +
	                        "SOAPAction: \"http://tempuri.org/SMSWebService/SMSService/sendMessage\""   + "\r\n\r\n";

	        String body =   "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "\r\n" +
	                        "<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" + "\r\n" +
	                        "<soap:Body>" + "\r\n" +
	                        "<sendMessage xmlns=\"http://tempuri.org/SMSWebService/SMSService\">" + "\r\n" +
	                        "<MobileNo>"+s1+"</MobileNo>" + "\r\n" +
	                        "<Message>"+s2+"</Message>" + "\r\n" +
	                        "<SMSAccount>OOADPJ2</SMSAccount>" + "\r\n" +
	                        "<SMSPassword>905357</SMSPassword>" + "\r\n" +
	                        "</sendMessage>" + "\r\n" +
	                        "</soap:Body>" + "\r\n" +
	                        "</soap:Envelope>" + "\r\n";
	        


	        try
	        {
	                // Create a socket and connect it to the SMTP server.
	            s = new Socket("172.20.128.62", 80);

	                // Get the communication streams.
	            pw = new PrintWriter(s.getOutputStream(), false);
	            br = new BufferedReader(new InputStreamReader(s.getInputStream()));

//	            System.out.println(header.replaceAll("\\$LEN", "new"));
	            
	                // Send the message.
	            pw.print(header.replaceAll("\\$LEN", "" + body.length()));            
	            pw.print(body);
	            pw.print("\r\n");
	            pw.flush();
	                      


	            String r = "";
	            
	            while((r = br.readLine()) != null) { System.out.println(r); }

	            
	            s.close();
	        }
	        catch(Exception ex)
	        {
	        }
	    }
		}

